package com.hjm.project.ActTerminalModel.ActTerminalModel.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ActTerminalModel.ActTerminalModel.domain.ActTerminalModel;
import com.hjm.project.ActTerminalModel.ActTerminalModel.service.IActTerminalModelService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 活动匹配终端Controller
 * 
 * @author ActTerminalModel
 * @date 2020-11-28
 */
@Controller
@RequestMapping("/ActTerminalModel/ActTerminalModel")
public class ActTerminalModelController extends BaseController
{
    private String prefix = "ActTerminalModel/ActTerminalModel";

    @Autowired
    private IActTerminalModelService actTerminalModelService;

    @RequiresPermissions("ActTerminalModel:ActTerminalModel:view")
    @GetMapping()
    public String ActTerminalModel()
    {
        return prefix + "/ActTerminalModel";
    }

    /**
     * 查询活动匹配终端列表
     */
    @RequiresPermissions("ActTerminalModel:ActTerminalModel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActTerminalModel actTerminalModel)
    {
        startPage();
        List<ActTerminalModel> list = actTerminalModelService.selectActTerminalModelList(actTerminalModel);
        return getDataTable(list);
    }

    /**
     * 导出活动匹配终端列表
     */
    @RequiresPermissions("ActTerminalModel:ActTerminalModel:export")
    @Log(title = "活动匹配终端", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActTerminalModel actTerminalModel)
    {
        List<ActTerminalModel> list = actTerminalModelService.selectActTerminalModelList(actTerminalModel);
        ExcelUtil<ActTerminalModel> util = new ExcelUtil<ActTerminalModel>(ActTerminalModel.class);
        return util.exportExcel(list, "ActTerminalModel");
    }

    /**
     * 新增活动匹配终端
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存活动匹配终端
     */
    @RequiresPermissions("ActTerminalModel:ActTerminalModel:add")
    @Log(title = "活动匹配终端", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActTerminalModel actTerminalModel)
    {
        return toAjax(actTerminalModelService.insertActTerminalModel(actTerminalModel));
    }

    /**
     * 修改活动匹配终端
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ActTerminalModel actTerminalModel = actTerminalModelService.selectActTerminalModelById(id);
        mmap.put("actTerminalModel", actTerminalModel);
        return prefix + "/edit";
    }

    /**
     * 修改保存活动匹配终端
     */
    @RequiresPermissions("ActTerminalModel:ActTerminalModel:edit")
    @Log(title = "活动匹配终端", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActTerminalModel actTerminalModel)
    {
        return toAjax(actTerminalModelService.updateActTerminalModel(actTerminalModel));
    }

    /**
     * 删除活动匹配终端
     */
    @RequiresPermissions("ActTerminalModel:ActTerminalModel:remove")
    @Log(title = "活动匹配终端", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actTerminalModelService.deleteActTerminalModelByIds(ids));
    }
}
